Avoid code duplication between stringified and
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 1 Sep 2005 09:37:54 +0000 (09:37 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 1 Sep 2005 09:37:54 +0000 (09:37 +0000)
non-stringified asm macros, by stringifying on use
where that is needed.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/include/asm-x86/asm_defns.h
xen/include/asm-x86/bitops.h
xen/include/asm-x86/x86_32/asm_defns.h
xen/include/asm-x86/x86_64/asm_defns.h
xen/include/xen/config.h

index 17777ad123a32bf3f581095af59ffd6d6f8dc7a0..c9ea4863a37b7d383cf82b4fbee06af43b2aeac0 100644 (file)
@@ -6,11 +6,6 @@
 #include <asm/asm-offsets.h>
 #include <asm/processor.h>
 
-#ifndef STR
-#define __STR(x) #x
-#define STR(x) __STR(x)
-#endif
-
 #ifdef __x86_64__
 #include <asm/x86_64/asm_defns.h>
 #else
index 9682ec96daec1db465cf909942887e1c658f5392..8bf54fcdc3a2db393fbc8162d56c9b7fe89f432e 100644 (file)
@@ -7,11 +7,6 @@
 
 #include <xen/config.h>
 
-#ifndef STR
-#define __STR(x) #x
-#define STR(x) __STR(x)
-#endif
-
 /*
  * These have to be done with inline assembly: that way the bit-setting
  * is guaranteed to be atomic. All bit operations return 0 if the bit
index 7ec44ec290ff09b5cbced832cc637d2f4b9f8550..d0243d4a52be3f04651879b22f35a4bcf67bb053 100644 (file)
@@ -1,46 +1,6 @@
 #ifndef __X86_32_ASM_DEFNS_H__
 #define __X86_32_ASM_DEFNS_H__
 
-/* Maybe auto-generate the following two cases (quoted vs. unquoted). */
-#ifndef __ASSEMBLY__
-
-#define __SAVE_ALL_PRE                                                  \
-        "cld;"                                                          \
-        "pushl %eax;"                                                   \
-        "pushl %ebp;"                                                   \
-        "pushl %edi;"                                                   \
-        "pushl %esi;"                                                   \
-        "pushl %edx;"                                                   \
-        "pushl %ecx;"                                                   \
-        "pushl %ebx;"                                                   \
-        "testl $"STR(X86_EFLAGS_VM)","STR(UREGS_eflags)"(%esp);"        \
-        "jz 2f;"                                                        \
-        "call setup_vm86_frame;"                                        \
-        "jmp 3f;"                                                       \
-        "2:testb $3,"STR(UREGS_cs)"(%esp);"                             \
-        "jz 1f;"                                                        \
-        "mov %ds,"STR(UREGS_ds)"(%esp);"                                \
-        "mov %es,"STR(UREGS_es)"(%esp);"                                \
-        "mov %fs,"STR(UREGS_fs)"(%esp);"                                \
-        "mov %gs,"STR(UREGS_gs)"(%esp);"                                \
-        "3:"
-
-#define SAVE_ALL_NOSEGREGS(_reg)                \
-        __SAVE_ALL_PRE                          \
-        "1:"
-
-#define SET_XEN_SEGMENTS(_reg)                                  \
-        "movl $("STR(__HYPERVISOR_DS)"),%e"STR(_reg)"x;"        \
-        "mov %e"STR(_reg)"x,%ds;"                              \
-        "mov %e"STR(_reg)"x,%es;"
-
-#define SAVE_ALL(_reg)                          \
-        __SAVE_ALL_PRE                          \
-        SET_XEN_SEGMENTS(_reg)                  \
-        "1:"
-
-#else
-
 #define __SAVE_ALL_PRE                                  \
         cld;                                            \
         pushl %eax;                                     \
@@ -50,7 +10,7 @@
         pushl %edx;                                     \
         pushl %ecx;                                     \
         pushl %ebx;                                     \
-        testl $X86_EFLAGS_VM,UREGS_eflags(%esp);        \
+        testl $(X86_EFLAGS_VM),UREGS_eflags(%esp);      \
         jz 2f;                                          \
         call setup_vm86_frame;                          \
         jmp 3f;                                         \
@@ -83,8 +43,6 @@
 #define PERFC_INCR(_name,_idx)
 #endif
 
-#endif
-
 #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
 #define XBUILD_SMP_INTERRUPT(x,v)               \
 asmlinkage void x(void);                        \
@@ -92,7 +50,7 @@ __asm__(                                        \
     "\n"__ALIGN_STR"\n"                         \
     STR(x) ":\n\t"                              \
     "pushl $"#v"<<16\n\t"                       \
-    SAVE_ALL(a)                                 \
+    STR(SAVE_ALL(a))                            \
     "call "STR(smp_##x)"\n\t"                   \
     "jmp ret_from_intr\n");
 
@@ -103,7 +61,7 @@ __asm__(                                        \
 "\n"__ALIGN_STR"\n"                             \
 STR(x) ":\n\t"                                  \
     "pushl $"#v"<<16\n\t"                       \
-    SAVE_ALL(a)                                 \
+    STR(SAVE_ALL(a))                            \
     "movl %esp,%eax\n\t"                        \
     "pushl %eax\n\t"                            \
     "call "STR(smp_##x)"\n\t"                   \
@@ -114,7 +72,7 @@ STR(x) ":\n\t"                                  \
 __asm__(                                        \
     "\n" __ALIGN_STR"\n"                        \
     "common_interrupt:\n\t"                     \
-    SAVE_ALL(a)                                 \
+    STR(SAVE_ALL(a))                            \
     "movl %esp,%eax\n\t"                        \
     "pushl %eax\n\t"                            \
     "call " STR(do_IRQ) "\n\t"                  \
index 60fd76d14aec40878c80f3b82663d1223ae1b450..ff1d4927e05f25c070ecbced725a81a915097b8c 100644 (file)
@@ -1,50 +1,6 @@
 #ifndef __X86_64_ASM_DEFNS_H__
 #define __X86_64_ASM_DEFNS_H__
 
-/* Maybe auto-generate the following two cases (quoted vs. unquoted). */
-#ifndef __ASSEMBLY__
-
-#define SAVE_ALL                                \
-        "cld;"                                  \
-        "pushq %rdi;"                           \
-        "pushq %rsi;"                           \
-        "pushq %rdx;"                           \
-        "pushq %rcx;"                           \
-        "pushq %rax;"                           \
-        "pushq %r8;"                            \
-        "pushq %r9;"                            \
-        "pushq %r10;"                           \
-        "pushq %r11;"                           \
-        "pushq %rbx;"                           \
-        "pushq %rbp;"                           \
-        "pushq %r12;"                           \
-        "pushq %r13;"                           \
-        "pushq %r14;"                           \
-        "pushq %r15;"
-
-#define RESTORE_ALL                             \
-        "popq  %r15;"                           \
-        "popq  %r14;"                           \
-        "popq  %r13;"                           \
-        "popq  %r12;"                           \
-        "popq  %rbp;"                           \
-        "popq  %rbx;"                           \
-        "popq  %r11;"                           \
-        "popq  %r10;"                           \
-        "popq  %r9;"                            \
-        "popq  %r8;"                            \
-        "popq  %rax;"                           \
-        "popq  %rcx;"                           \
-        "popq  %rdx;"                           \
-        "popq  %rsi;"                           \
-        "popq  %rdi;"
-
-/* Work around AMD erratum #88 */
-#define safe_swapgs                             \
-        "mfence; swapgs;"
-
-#else
-
 #define SAVE_ALL                                \
         cld;                                    \
         pushq %rdi;                             \
@@ -90,7 +46,9 @@
 #define PERFC_INCR(_name,_idx)
 #endif
 
-#endif
+/* Work around AMD erratum #88 */
+#define safe_swapgs                             \
+        "mfence; swapgs;"
 
 #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
 #define XBUILD_SMP_INTERRUPT(x,v)               \
@@ -100,7 +58,7 @@ __asm__(                                        \
     STR(x) ":\n\t"                              \
     "pushq $0\n\t"                              \
     "movl $"#v",4(%rsp)\n\t"                    \
-    SAVE_ALL                                    \
+    STR(SAVE_ALL)                               \
     "callq "STR(smp_##x)"\n\t"                  \
     "jmp ret_from_intr\n");
 
@@ -112,7 +70,7 @@ __asm__(                                        \
 STR(x) ":\n\t"                                  \
     "pushq $0\n\t"                              \
     "movl $"#v",4(%rsp)\n\t"                    \
-    SAVE_ALL                                    \
+    STR(SAVE_ALL)                               \
     "movq %rsp,%rdi\n\t"                        \
     "callq "STR(smp_##x)"\n\t"                  \
     "jmp ret_from_intr\n");
@@ -121,7 +79,7 @@ STR(x) ":\n\t"                                  \
 __asm__(                                        \
     "\n" __ALIGN_STR"\n"                        \
     "common_interrupt:\n\t"                     \
-    SAVE_ALL                                    \
+    STR(SAVE_ALL)                               \
     "movq %rsp,%rdi\n\t"                        \
     "callq " STR(do_IRQ) "\n\t"                 \
     "jmp ret_from_intr\n");
index ca3650f80fb59150908fa67cd4726274c8c02912..e59bb86a7c7355f23be1d6201b3aaa09204000a7 100644 (file)
@@ -40,4 +40,7 @@
 #include <xen/compiler.h>
 #endif
 
+#define __STR(...) #__VA_ARGS__
+#define STR(...) __STR(__VA_ARGS__)
+
 #endif /* __XEN_CONFIG_H__ */